class_name PlayerSwordAttackState
extends GameplayState

var combo_counter: int = 0

var combo_window: int = 2

var combo_time: float = 2.0

@onready var player: Player = $"../../../"


func _on_enter() -> void:
	if player.state_machine.blackboard["combo_timer"] > 0.0:
		combo_counter = (combo_counter + 1) % combo_window
	else:
		combo_counter = 0
	
	player.state_machine.blackboard["combo_timer"] = combo_time
	
	player.play_animation("sword_attack" + str(combo_counter + 1))
	player.weapon.play_animation("attack" + str(combo_counter + 1))

	player.velocity = Vector2.ZERO


func _on_update(_delta: float) -> void:
	if not player.weapon.animator.is_playing():
		change_state("GhostState", func(): pass)
